Page({
  data: {
    achievements: [], // 学习成就列表
  },

  onLoad() {
    // 加载学习成就数据
    this.loadAchievements();
  },

  // 加载学习成就数据
  loadAchievements() {
    const achievements = [
      {
        id: 1,
        icon: '/pages/images/icon/achievement1.png',
        name: '完成每日打卡: ',
        description: '连续7天完成每日打卡任务',
      },
      {
        id: 2,
        icon: '/pages/images/icon/achievement2.png',
        name: '学习达人',
        description: '累计学习时长达到10小时',
      },
      {
        id: 3,
        icon: '/pages/images/icon/achievement3.png',
        name: '专注高手',
        description: '连续5天保持专注学习模式',
      },
    ];
    this.setData({ achievements });
  },

  // 查看成就详情
  viewAchievementDetail(e) {
    const achievementId = e.currentTarget.dataset.id;
    const achievement = this.data.achievements.find(item => item.id === achievementId);

    wx.showModal({
      title: '成就详情',
      content: `名称：${achievement.name}\n描述：${achievement.description}`,
      showCancel: false,
    });
  },
});